#!/bin/sh

psql -U srb MCAT -t -c "select 'SmodifyUser changeUserAddress '||user_name||' '||zone_id||' \"'||user_address||'\"' from mdas_cd_user, mdas_au_info where mdas_cd_user.user_id=mdas_au_info.user_id and length(user_address)>0 and zone_id in (select zone_id from mdas_td_zone where local_zone_flag=1) and mdas_cd_user.user_id>101 and ( mdas_cd_user.user_typ_id like '0001.0001.0001.0001.000%' or mdas_cd_user.user_typ_id = '0002') and user_name not in (select zone_id from mdas_td_zone)"
psql -U srb MCAT -t -c "select 'SmodifyUser changeUserEmail '||user_name||' '||zone_id||' \"'||user_email||'\"' from mdas_cd_user, mdas_au_info where mdas_cd_user.user_id=mdas_au_info.user_id and length(user_email)>0 and zone_id in (select zone_id from mdas_td_zone where local_zone_flag=1) and mdas_cd_user.user_id>101 and ( mdas_cd_user.user_typ_id like '0001.0001.0001.0001.000%' or mdas_cd_user.user_typ_id = '0002') and user_name not in (select zone_id from mdas_td_zone)"
psql -U srb MCAT -t -c "select 'SmodifyUser changeUserPhone '||user_name||' '||zone_id||' \"'||user_phone||'\"' from mdas_cd_user, mdas_au_info where mdas_cd_user.user_id=mdas_au_info.user_id and length(user_phone)>0 and zone_id in (select zone_id from mdas_td_zone where local_zone_flag=1) and mdas_cd_user.user_id>101 and ( mdas_cd_user.user_typ_id like '0001.0001.0001.0001.000%' or mdas_cd_user.user_typ_id = '0002') and user_name not in (select zone_id from mdas_td_zone)"
psql -U srb MCAT -t -c "select 'SmodifyUser addDN '||user_name||' '||zone_id||' \"'||distin_name||'\"' from mdas_cd_user, mdas_au_auth_map where mdas_cd_user.user_id=mdas_au_auth_map.user_id and length(distin_name)>0 and auth_scheme_id=2 and zone_id in (select zone_id from mdas_td_zone where local_zone_flag=1) and mdas_cd_user.user_id>101 and ( mdas_cd_user.user_typ_id like '0001.0001.0001.0001.000%' or mdas_cd_user.user_typ_id = '0002') and user_name not in (select zone_id from mdas_td_zone)"
